package com.xianyun.rpc.fault.tolerant;

import com.xianyun.rpc.model.RpcResponse;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

/**
 * 失败返回
 */
@Slf4j
public class FailBackTolerantStrategy implements TolerantStrategy {

    @Override
    public RpcResponse doTolerant(Map<String, Object> context, Exception e) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setException(e);
        rpcResponse.setMessage("服务调用失败");
        log.error("服务调用失败", e);
        return rpcResponse;
    }
}